home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Purity / Purity #22 (1994-01-19)(Diesel)(DE)[WB].zip / Purity #22 (1994-01-19)(Diesel)(DE)[WB].adf / ClockUnit / ClockUnit.pas next >
Pascal/Delphi Source File  |  1994-01-17  |  2KB  |  60 lines

  1. {****************************************************************}
  2. { ClockUnit                                                      }
  3. {                                                                }
  4. { By Hans Luyten , Using HighSpeed Pascal 1.10 with OS2.0 Units. }
  5. { A small demo on how to read the clock using OS2.x and higher.  }
  6. { Uses Utility.library and Battclock.resource !!                 }
  7. { NOTE: This will NOT work on systems with <OS2.0 !!             }
  8. {****************************************************************}
  9. Unit ClockUnit;
  10.  
  11. INTERFACE
  12.  
  13. Uses Exec, Utility, BattClock;
  14.   
  15. VAR
  16.   Current  : pClockData;      { Need this for clock data -> Utility unit }
  17.  
  18. FUNCTION GetTimeDate(VAR Hour,Min,Sec,Day,Month,Year:Word; 
  19.                       VAR WDay:string):BOOLEAN;
  20.                       
  21. IMPLEMENTATION
  22.  
  23. FUNCTION GetTimeDate(VAR Hour,Min,Sec,Day,Month,Year:Word; 
  24.                       VAR WDay:string):BOOLEAN;
  25. BEGIN
  26.   UtilityBase:=OpenLibrary('utility.library',36); { Open utility.library }
  27.   BattClockBase:=OpenResource(BATTCLOCKNAME);     { Open resource        }
  28.  
  29.   IF (BattClockBase<>NIL)AND(UtilityBase<>NIL) THEN  { All opened ??     }
  30.     BEGIN
  31.     
  32.       NEW(Current);                      { Allocate memory for ClockData }
  33.       Amiga2Date(ReadBattClock,Current); { Convert AmigaData->NormalDate }
  34.       
  35.       Hour:=Current^.hour;
  36.       Min:=Current^.min;
  37.       Sec:=Current^.sec;
  38.       Day:=Current^.mday;
  39.       Month:=Current^.month;
  40.       Year:=Current^.year;
  41.       CASE Current^.wday OF
  42.         1: WDay:='Monday';               { Current^.wday=1 }
  43.         2: WDay:='Tuesday';              { Current^.wday=2 }
  44.         3: WDay:='Wednesday';            { Current^.wday=3 }
  45.         4: WDay:='Thursday';             { Current^.wday=4 }
  46.         5: WDay:='Friday';               { Current^.wday=5 }
  47.         6: WDay:='Saturday';             { Current^.wday=6 }
  48.         7: WDay:='Sunday';               { Current^.wday=7 }
  49.       END;
  50.       
  51.       CloseLibrary(UtilityBase);         { Close utility.library         }
  52.       GetTimeDate:=TRUE;
  53.     END
  54.   ELSE
  55.     GetTimeDate:=FALSE;
  56. END;
  57.  
  58. BEGIN
  59. END.
  60.